home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Adobe Graphics & Publishing SDK 1996 December
/
Adobe Graphics & Publishing SDK 1996 December.iso
/
mac
/
After Effects 3.1 SDK Mac
/
Examples
/
I⁄O Samples
/
Filmstrip FXIF
/
FILM_Add.c
next >
Wrap
Text File
|
1996-06-04
|
4KB
|
224 lines
/**
FILM_Add.c
Part of the Adobe After Effects 3.1 SDK
Copyright (c)1993-96, Adobe Systems Inc, All Rights Reserved.
Revision History
1.0, created by dmw
**/
#include "PIFormatT.h"
#include "Film.h"
static OSErr SetFilmstripRec (
short fRefNum,
FilmStripRec *filmstrip )
{
OSErr err = 0;
long count = sizeof(FilmStripRec);
err = SetFPos(fRefNum, fsFromLEOF, -sizeof(FilmStripRec));
if (!err) {
err = FSWrite(fRefNum, &count, filmstrip);
}
return err;
}
void StartAddPrepare (Ptr Stuff, long *data, short *result)
{
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
*result = 0;
}
void StartAddStart (Ptr Stuff, long *data, short *result)
{
OSErr err;
FormatRecordTPtr fpt = (FormatRecordTPtr)(Stuff - sizeof(TimeExtension));
myRevertInfo **ri;
TimeInfoHandle ti;
GWorldPtr gworld = NULL;
Rect grect;
ti = fpt->time_ext.time_info;
ri = (myRevertInfo**) NewHandle(sizeof(myRevertInfo));
if (ri) {
long i;
fpt->revertInfo = (Handle)ri;
DH(ri)->rowsat = 0;
DH(ri)->dataH = NULL;
DH(ri)->film_rec.signature = 'Rand';
DH(ri)->film_rec.numFrames = 0;
DH(ri)->film_rec.duration = 0;
DH(ri)->film_rec.width = fpt->imageSize.h;
DH(ri)->film_rec.height = fpt->imageSize.v;
DH(ri)->film_rec.leading = FILM_LEAD;
DH(ri)->film_rec.framesPerSec = (DH(ti)->write_fixed_fps) >> 16;
DH(ri)->film_rec.flags = 0;
for (i=0; i<12; i++)
DH(ri)->film_rec.spare[i] = 0;
grect.left = grect.top = 0;
grect.right = fpt->imageSize.h;
grect.bottom = FILM_LEAD;
err = NewGWorld(&gworld, 32, &grect, NULL, NULL, keepLocal);
if (!err) {
DH(ri)->number_wld = gworld;
}
} else {
err = memFullErr;
}
if (err) {
if (ri) {
DisposeHandle((Handle)ri);
fpt->revertInfo = NULL;
}
if (gworld) {
DisposeGWorld(gworld);
}
}
*result = err;
}
void StartAddContinue (Ptr Stuff, long *data, short *result)
{
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
*result = 0;
}
void StartAddFinish (Ptr Stuff, long *data, short *result)
{
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
*result = 0;
}
void EndAddPrepare (Ptr Stuff, long *data, short *result)
{
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
*result = 0;
}
void EndAddStart (Ptr Stuff, long *data, short *result)
{
OSErr err = 0;
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
FormatRecordTPtr fpt = (FormatRecordTPtr)(Stuff - sizeof(TimeExtension));
myRevertInfo **ri;
TimeInfoHandle ti;
Handle yellowbarsH;
long *yellowP;
long black = 0;
long yellow = 0xFFFF00FF;
ti = fpt->time_ext.time_info;
ri = (myRevertInfo**) fpt->revertInfo;
if (ri) {
long yellow_sz, i;
long bytes_written;
err = SetFPos(fpt->dataFork, fsFromLEOF, 0);
if (!err) {
yellow_sz = (long)(fp->imageSize.h + FILM_TRAIL);
// one scanline of yellow/black stripe
yellowbarsH = NewHandle(yellow_sz * sizeof(long));
if (yellowbarsH) {
HLock(yellowbarsH);
yellowP = (long*)*yellowbarsH;
for (i=0; i<yellow_sz; i++) {
if (i&4)
*yellowP = black;
else
*yellowP = yellow;
yellowP++;
}
yellowP = (long*)*yellowbarsH;
for (i=0; i<FILM_TRAIL; i++) {
bytes_written = fp->imageSize.h * sizeof(long);
err = FSWrite(fpt->dataFork, &bytes_written, yellowP);
if (err) break;
yellowP++;
}
DisposeHandle(yellowbarsH);
if (!err) {
FilmStripRec rec;
rec = DH(ri)->film_rec;
rec.duration = 30.0 * rec.numFrames / (double)rec.framesPerSec;
err = SetFilmstripRec(fp->dataFork, &rec);
}
} else {
err = memFullErr;
}
}
} else {
err = formatBadParameters;
}
if (fp->revertInfo) {
myRevertInfo **ri = (myRevertInfo**)fp->revertInfo;
if (DH(ri)->number_wld) {
DisposeGWorld(DH(ri)->number_wld);
DH(ri)->number_wld = NULL;
}
DisposHandle(fp->revertInfo);
}
fp->revertInfo = NULL;
*result = err;
}
void EndAddContinue (Ptr Stuff, long *data, short *result)
{
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
*result = 0;
}
void EndAddFinish (Ptr Stuff, long *data, short *result)
{
FormatRecordPtr fp = (FormatRecordPtr)Stuff;
*result = 0;
}